package myTestSel;

import org.junit.Test;
import org.openqa.selenium.By;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.WebElement;
import org.openqa.selenium.chrome.ChromeDriver;

public class SeleniumTest {

    @Test
    public void t() {
        System.setProperty("webdriver.chrome.driver","D:\\ChromeCoreDownloads\\chromedriver_win32\\chromedriver.exe");
        WebDriver driver=new ChromeDriver();

        driver.manage().window().maximize();
        // driver.get("https://blog.csdn.net/weixin_46195957?spm=1001.2014.3001.5343");
        driver.get("https://www.baidu.com");
        //定位输入框元素
        WebElement txtbox = driver.findElement(By.id("kw"));
        //在百度输入框输入文本
        txtbox.sendKeys("csdn");
        //定位"百度一下"按钮元素
        WebElement btn = driver.findElement(By.id("su"));
        //点击按钮
        btn.click();
        //获取 title 和 URL 地址并输入到控制台
        String title = driver.getTitle();
        String url = driver.getCurrentUrl();
        System.out.println(title + ":" + url);
        //关闭
        driver.close();
    }
}